package com.baidu.shoppingmall.common.domain;

import com.baidu.shoppingmall.common.util.BeanCopierUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author yjf
 */
public class POJOParent {

    private static final Logger logger = LoggerFactory.getLogger(POJOParent.class);

    /**
     * 克隆方法
     *
     * @param clazz 目标Class对象
     * @return 克隆后的对象
     */
    public <T> T clone(Class<T> clazz) {
        T target = null;

        try {
            target = clazz.newInstance();
        } catch (Exception e) {
            logger.error("error", e);
        }

        BeanCopierUtils.copyProperties(this, target);

        return target;
    }
}
